Discussion:
Use .NET dll in Navision
(too old to reply)
einar
2004-12-28 08:45:02 UTC
Permalink
Does any one know of a good way to use .NET assembly in MBS Navision. I hvae
tried to use regasm.exe to register the dll as a COM object but it is not
working
Henrik Skydtsgaard Nielsen [MSFT]
2004-12-29 20:07:06 UTC
Permalink
Hi Einar,

To use a .NET class in Navision you need to make it COM compatible and make
interfaces for the method properties you want to expose.
In Visual Studio under project/"Project Name"-properties/Configuration
Properties/Build you should set the property "Register for Com Interop" =
true, then VS will register the class for you.

I made a sample, which I hope can help you.

using System;
using System.Runtime.InteropServices;

namespace navisioncom
{

[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]

public interface INavisionTest
{
int Add2Numbers(int a,int b);
}

[ClassInterface(ClassInterfaceType.None)]
//[GuidAttribute("59e333c0-c400-333e-333c-88486333104c")] use this if you
will keep the same GUID for the Class everytime you compile. Use a unique GUID
public class NavisionTest : INavisionTest
{
public NavisionTest()
{
}
public int Add2Numbers(int a,int b)
{
return(a+b);
}
}
}

In Navision you can create a testprogram

create a variable like this.
Name DataType Subtype Length
navi Automation 'navisioncom'.NavisionTest

And the simple test program.

OnRun()
CREATE(navi);
MESSAGE (FORMAT(navi.Add2Numbers(1,2)));


Hope this will help you.

Best regards
Henrik Skydtsgaard
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Post by einar
Does any one know of a good way to use .NET assembly in MBS Navision. I hvae
tried to use regasm.exe to register the dll as a COM object but it is not
working
Rajesh Veluswamy [MSFT]
2005-01-05 13:52:57 UTC
Permalink
Hi,

There a more elloborate documentation about How to access .NET components
from COM clients:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconexposingnetframeworkcomponentstocom.asp
Post by einar
Does any one know of a good way to use .NET assembly in MBS Navision. I hvae
tried to use regasm.exe to register the dll as a COM object but it is not
working
Loading...